package com.ljty.sql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import com.ljty.gui.LoginView;
public class LoginModel
	{
		private String OperatorNum;
		private String OperatorName;
		private String OperatorPassword;
		private String OperatorLevel;
		private String DataTime;
		DBcon odb = new DBcon();
		private String sql;
		public String getOperatorNum()
			{
				return OperatorNum;
			}

		public void setOperatorNum(String OperatorNum)
			{
				this.OperatorNum = OperatorNum;
			}

		public String getOperatorName()
			{
				return OperatorName;
			}

		public void setOperatorName(String OperatorName)
			{
				this.OperatorName = OperatorName;
			}

		public String getOperatorPassword()
			{
				return OperatorPassword;
			}

		public void setOperatorPassword(String OperatorPassword)
			{
				this.OperatorPassword = OperatorPassword;
			}

		public String getOperatorLevel()
			{
				return OperatorLevel;
			}

		public void setOperatorLevel(String OperatorLevel)
			{
				this.OperatorLevel = OperatorLevel;
			}

		public String getDataTime()
			{
				return DataTime;
			}

		public void setDataTime(String DataTime)
			{
				this.DataTime = DataTime;
			}

		public boolean select()
			{
				boolean flag = true;
				sql = "select OperatorPassword,OperatorLevel  from Operatorinformation where OperatorName='" + OperatorName
						+ "'";
				Connection conn = odb.getConn();
				try
					{
						Statement stmt = conn.createStatement();
						ResultSet rs = stmt.executeQuery(sql);
						flag=rs.next();
						if (flag)
							{
								OperatorPassword = rs.getString(1).trim();
								OperatorLevel = rs.getString(2).trim();
							}
						rs.close();
						stmt.close();
						conn.close();

					} catch (Exception ex)
					{

						// TODO: handle exception
						System.out.println("ex:" + ex.getMessage());
					}

				return flag;

			}
	}
